class PistonHeadRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	PistonHeadRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data) { return data; }

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		byte dir = block.Data & ~0x08;
		bool sticky = (block.Data & 0x08) != 0;

		switch (dir)
		{
		case 0:
			renderer->Translate(8, 8, 8);
			renderer->Rotate(180, 1, 0, 0);
			renderer->Translate(-8, -8, -8);
			break;
		case 1:
			break;
		case 2:
			renderer->Translate(8, 8, 8);
			renderer->Rotate(90, 1, 0, 0);
			renderer->Translate(-8, -8, -8);
			break;
		case 3:
			renderer->Translate(8, 8, 8);
			renderer->Rotate(180, 0, 1, 0);
			renderer->Rotate(90, 1, 0, 0);
			renderer->Translate(-8, -8, -8);
			break;
		case 4:
			renderer->Translate(8, 8, 8);
			renderer->Rotate(90, 0, 1, 0);
			renderer->Rotate(90, 1, 0, 0);
			renderer->Translate(-8, -8, -8);
			break;
		case 5:
			renderer->Translate(8, 8, 8);
			renderer->Rotate(-90, 0, 1, 0);
			renderer->Rotate(90, 1, 0, 0);
			renderer->Translate(-8, -8, -8);
			break;
		}

		renderer->Draw(Box(Texture, Point3i(16, 4, 16)).SetSides(Point2i(12 * 16, 6 * 16)).SetBottom(Point2i(11 * 16, 6 * 16)).SetTop(Point2i((sticky ? 10 : 11) * 16, 6 * 16)));

		renderer->Translate(8, 8, 8);
		renderer->Rotate(90, 0, 0, 1);
		renderer->Translate(-8, -8, -8);

		for (int i = 0; i < 4; ++i)
		{
			renderer->Translate(8, 8, 8);
			renderer->Rotate(90, 1, 0, 0);
			renderer->Translate(-8, -8, -8);

			renderer->Draw(Face(Point3f(20, 6, 6), Point3f(4, 6, 6), Point3f(4, 10, 6), Point3f(20, 10, 6), Colorb::White, Texture, Point2i(12 * 16, 6 * 16), 16, 4));
		}
	}
};